<template>
  <div class="info" v-if="Object.keys(info).length !== 0">
    <div class="desc fix">
      <div class="start"></div>
      <div class="desc">{{ info.desc }}</div>
      <div class="end"></div>
    </div>
    <div class="key">{{ info.detailImage[0].key }}</div>
    <div class="list">
      <img
        v-for="(item, index) in info.detailImage[0].list"
        :key="index"
        :src="item"
        @load="imageload"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'info',
  data() {
    return {
      counter: 0, // 没加载一个图片都会加1
      imageLength: 0, //图片的长度
    }
  },
  props: {
    info: {
      type: Object,
    },
  },
  methods: {
    imageload() {
      // 所有图片都加载完了 在进行回调          1.拿到图片的长度
      this.counter += 1
      //  console.log(this.counter);
      if (this.counter === this.imageLength) {
        this.$emit('imageLoad')
      }
    },
  },
  watch: {
    info() {
      //监听info 获取图片格数
      this.imageLength = this.info.detailImage[0].list.length
    },
  },
}
</script>
<style scoped>
.info {
  padding: 20px 0;
  border-bottom: 5px solid #f2f5f8;
}
.desc {
  padding: 0 15px;
}

.desc .start,
desc .end {
  width: 90px;
  height: 1px;
  background-color: #a3a3a5;
  position: absolute;
}

.desc .start {
  float: left;
}

.desc .end {
  float: right;
}

.desc .start::before,
.desc .end::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background-color: #333;
  bottom: 0;
}

.desc .end::after {
  right: 0;
}

.desc .desc {
  padding: 15px 0;
  font-size: 14px;
}

.key {
  margin: 10px 0 10px 15px;
  color: #333;
  font-size: 15px;
}

.list img {
  width: 100%;
}
</style>
